<template>
  <div class="execution">
    <basic-container>
      <avue-crud
        v-model="form"
        v-bind="bindVal"
        v-on="onEvent"
        :page.sync="page"
        :permission="permissionList">
        <template slot="menuLeft">
          <el-popover v-if="permissions.stm_swstcycleapply_audit" placement="bottom" width="260" v-model="batchReviewVisible">
            <div style="text-align: center; margin: 0">
              <el-button size="mini" type="primary" @click="batchReview(2)">审批通过</el-button>
              <el-button type="primary" size="mini" @click="batchReview(3)">审批不通过</el-button>
            </div>
            <el-button type="primary" size="small"  slot="reference">批量审批</el-button>
          </el-popover>
        </template>
      </avue-crud>
    </basic-container>
  </div>
</template>

<script>
  import baseCrud from '@/mixins/base-crud'
  import {appBatch} from '@/api/subwaystm/swstcycleapply'
  import { startDate, endDate } from "@/const/crud/subway/swstcycleaudit";

  export default {
    name: 'StCycleAudit',
    mixins: [baseCrud('subway/swstcycleaudit')],
    data() {
      return {
        batchReviewVisible: false,
        searchForm: {
          dates1: [startDate, endDate]
        }
      }
    },
    computed: {
      permissionList() {
        return {}
      }
    },
    methods: {
      batchReview(status) {
        var tableSelect = this.$refs.crud.tableSelect
        if (tableSelect.length == 0) {
          this.$message.info("请选择要审批的数据");
          return;
        }
        for (const table of tableSelect) {
          table.reviewStatus = status
        }
        appBatch(tableSelect).then(data => {
          this.$message.success("审批成功");
          this.getList(this.page);
          this.batchReviewVisible = false;
        });
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>
